package com.wanggsx.library.base.http;


import com.wanggsx.library.base.app.init.AppConstant;
import com.wanggsx.library.base.app.needextends.SuperAppInstance;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class HttpClient {

    public static void init(){
        HttpLogInterceptor logging = new HttpLogInterceptor();
        logging.setLevel(HttpLogInterceptor.Level.BODY);

        SuperAppInstance.okHttpClient = new OkHttpClient.Builder()
                .addInterceptor(logging)
                .connectTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(60, TimeUnit.MINUTES) // write timeout
                .readTimeout(60, TimeUnit.MINUTES)// read timeout
                .build();

        SuperAppInstance.retrofit = new Retrofit.Builder()
                .baseUrl(AppConstant.netWorkPrifix)
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .client(SuperAppInstance.okHttpClient)
                .build();
    }

}
